/*
 * 练习1：创建一个简单的类。在第二个类中，将一个引用定义为第一个类的对象，
 *      运用初始化来实例化这个对象。
 */
package chapter7_Reusing;
import publicLibs.p;

class Engine {
	private String s;
	Engine() {
		p.p("Engine()");
		s = "Constructed";
	}
	public String toString() { return s; }
}

public class E1_Airplane {
	private String fuselage, wings, tail;
	private Engine e;
	public E1_Airplane() {
		p.p("Inside E1_Airplane()");
		fuselage = "Body";
		wings = "Airfoils";
		tail = "Empennage";				
	}
	public String toString() { 
		if(e == null) // lazy (delayed) initialization:
			e = new Engine();
		return "fuselage = " + fuselage + "\r\n" +
			"wings = " + wings + "\r\n" +
			"tail = " + tail + "\r\n" +
			"Engine = " + e;
	}
	public static void main(String[] args) {
		E1_Airplane N1234 = new E1_Airplane();
		p.p(N1234);
	}
}


